package global_village.data;

import org.json.JSONObject;

import android.util.Log;
import static global_village.data.Constants.*;

/**
 * This class represent a group object.
 * Group fields :
 * String id - the id of the group.
 * String name - the name of the group.
 * String img - the name of the image.
 * 
 * @author Noam Tzumie
 *
 */
public class Group {

	private static final String TAG = Group.class.getSimpleName();
	
	private JSONObject groupJson;
	
	public Group(){
		groupJson = new JSONObject();
	}
	
	public Group(JSONObject groupJson){
		this.groupJson = groupJson;
	}
	
	@Override
	public String toString() {
		return groupJson.toString();
	}

	public String getId(){
		try{
			return groupJson.getString(GROUP_ID);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
		return null;
	}
	
	public void setId(String id){
		try{
			groupJson.put(GROUP_ID, id);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
	}
	
	public String getName(){
		try{
			return groupJson.getString(GROUP_NAME);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
		return null;
	}
	
	public void setName(String name){
		try{
			groupJson.put(GROUP_NAME, name);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
	}
	
	public String getImg(){
		try{
			return groupJson.getString(GROUP_IMG);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
		return null;
	}
	
	public void setImg(String img){
		try{
			groupJson.put(GROUP_IMG, img);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
	}
	public String getType(){
		try{
			return groupJson.getString(GROUP_TYPE);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
		return null;
	}
	
	public void setType(String type){
		try{
			groupJson.put(GROUP_TYPE, type);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
	}
	
	public JSONObject getLocation(){
		try{
			return groupJson.getJSONObject(GROUP_LOCATION);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
		return null;
	}
	
	public void setLocation(JSONObject location){
		try{
			groupJson.put(GROUP_LOCATION, location);
		}catch (Exception e) {
			Log.e(TAG,e.toString());
		}
	}
}
